package com.example.demo.future;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @description: xxx
 * @time: 2020-12-12 12:32
 * @author: baojinlong
 **/
public class JDKThreadPoolExecutorTest {
    // execute 方式提交，不关心返回值的，直接往线程池里面扔任务就完事
    // 当所有非守护线程退出时， JVM 才会退出， Main 方法主线程和 Worker 线程都是非守护线程
    public static void main(String[] args) throws Exception {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 5, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10));
        //execute(Runnable command)方法。没有返回值
        executor.execute(() -> System.out.println("关注why技术"));
        //Thread.currentThread().join();
        System.out.println("all ok");
    }


}
